/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author tra
 */
@Entity
@Table(name = "ALBUM_ARTIST")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AlbumArtist.findAll", query = "SELECT a FROM AlbumArtist a"),
    @NamedQuery(name = "AlbumArtist.findByAlbumArtistId", query = "SELECT a FROM AlbumArtist a WHERE a.albumArtistId = :albumArtistId")})
public class AlbumArtist implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ALBUM_ARTIST_ID")
    private Long albumArtistId;
    @JoinColumn(name = "ARTIST_ID", referencedColumnName = "ARTIST_ID")
    @ManyToOne(optional = false)
    private Artist artistId;
    @JoinColumn(name = "ALBUM_ID", referencedColumnName = "ALBUM_ID")
    @ManyToOne(optional = false)
    private Album albumId;

    public AlbumArtist() {
    }

    public AlbumArtist(Long albumArtistId) {
        this.albumArtistId = albumArtistId;
    }

    public Long getAlbumArtistId() {
        return albumArtistId;
    }

    public void setAlbumArtistId(Long albumArtistId) {
        Long oldAlbumArtistId = this.albumArtistId;
        this.albumArtistId = albumArtistId;
        changeSupport.firePropertyChange("albumArtistId", oldAlbumArtistId, albumArtistId);
    }

    public Artist getArtistId() {
        return artistId;
    }

    public void setArtistId(Artist artistId) {
        Artist oldArtistId = this.artistId;
        this.artistId = artistId;
        changeSupport.firePropertyChange("artistId", oldArtistId, artistId);
    }

    public Album getAlbumId() {
        return albumId;
    }

    public void setAlbumId(Album albumId) {
        Album oldAlbumId = this.albumId;
        this.albumId = albumId;
        changeSupport.firePropertyChange("albumId", oldAlbumId, albumId);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (albumArtistId != null ? albumArtistId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AlbumArtist)) {
            return false;
        }
        AlbumArtist other = (AlbumArtist) object;
        if ((this.albumArtistId == null && other.albumArtistId != null) || (this.albumArtistId != null && !this.albumArtistId.equals(other.albumArtistId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.AlbumArtist[ albumArtistId=" + albumArtistId + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
